import { get, post } from '@/utils/request'

export default class Letter {
  /**
   * 获取未读消息数量
   *
   */
  static async getLetterUnreadCount() {
    return get('/letter/unread/count')
  }

  /**
   * 获取私信列表
   * @param {int} current 当前页码
   * @param {int} limit 每页条数
   * @returns
   */
  static async getLetterList(current = 1, limit = 5) {
    return get('/letter/list', {
      current,
      limit
    })
  }

  /**
   * 获取私信详情
   * @param {string} id 私信conversation_id
   * @param {int} current 当前页码
   * @param {int} limit 每页条数
   * @returns
   */
  static async getLetterDetail(id, current = 1, limit = 5) {
    return get('/letter/detail/' + id, {
      current,
      limit
    })
  }

  /**
   * 获取私信数量
   * @param {string} id 私信conversation_id
   * @returns
   */
  static async getLetterCount(id) {
    return get('/letter/detail/' + id + '/count')
  }

  /**
   * 发送私信
   * @param {string} toName 接收用户名称
   * @param {string} content 私信内容
   * @returns
   */
  static async sendLetter(toName, content) {
    return post('/letter/send', {
      toName,
      content
    })
  }
}
